﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace FooFun.Web.Controls
{
    public class PagedDataElement : DataElementControl
    {
        private int pageSize = 0;

        protected int PageSize
        {
            get { return pageSize; }
            set { pageSize = value; }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            List<PagerControl> list = new List<PagerControl>();
            foreach (Control ctr in this.Controls)
            {
                if (ctr is PagerControl)
                {
                    PagerControl c = ctr as PagerControl;
                    list.Add(c);
                    if (c.PageSize > pageSize)
                    {
                        pageSize = c.PageSize;
                    }
                }
            }

            if (pageSize < 1)
            {
                pageSize = 20;
            }

            foreach (PagerControl ctr in list)
            {
                ctr.PageSize = pageSize;
            }
        }

        public int TotalCount { get; set; }
    }
}
